<?php
include '../business/dao/BaseDataAccess.php';
include '../business/dao/NewsAccess.php';
include '../business/model/model.php';
ini_set('display_errors',1);

$newsDao = new NewsDao();

$action = $_POST["act"];
$id = $_POST["id"];

if ("delete" == $action) {
	$newsDao->deleteNew($id);
	echo "success";
} else if ("save" == $action) {
	$new = new News();
	$new->setId($_POST["id"]);
	$new->setTitle($_POST["title"]);
	$new->setAuthor($_POST["author"]);
	$new->setContent($_POST["content"]);
	if ($new->getId() != null) {
		$newsDao->updateNew($new);
		echo "success";
	} else {
		$newsDao->addNew($new);
		echo "success";
	}
}
?>